home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 223_01 / strncmp.c < prev    next >
Text File  |  1980-01-01  |  512b  |  14 lines

  1. /*
  2. ** strncmp(s,t,n) - Compares two strings for at most n
  3. **                  characters and returns an integer
  4. **                  >0, =0, or <0 as s is >t, =t, or <t.
  5. */
  6. strncmp(s, t, n) char *s, *t; int n; {
  7.   while(n && *s==*t) {
  8.     if (*s == 0) return (0);
  9.     ++s; ++t; --n;
  10.     }
  11.   if(n) return (*s - *t);
  12.   return (0);
  13.   }
  14.